date count package
3829 2025-06-25 54021 ggplot2
3830 2025-06-26 50323 ggplot2
3831 2025-06-27 50306 ggplot2
3832 2025-06-28 31488 ggplot2
3833 2025-06-29 33328 ggplot2
3834 2025-06-30 48941 ggplot2
The most popular data visualization framework in R
2025-07-23
ggplot2 is the most downloaded R library in the world
Part of the tidyverse suite of packages, ggplot2 offers great consistency with dplyr pipes and syntax, with one very notable exception: the use of + instead of %>% to connect functions/verbs
“gg” refers to “The Grammar of Graphics,” a 1999 book from Leland Wilkinson that laid out a framework for creating statistical graphics in layered components
The “2” in ggplot2 alludes to the fact that this package supplants an older, less efficient library called ggplot, but since the developer wanted to support legacy usage of the older library, both packages were maintained for a period of time. Nevertheless, ggplot() remains as the main function in ggplot2
Easy to start with some minimally viable code for a plot, but how does one make a cleaner and more polished graph?
By utilizing rest of the components, one can add more features to the graph and also clean up unnecessary elements
Implement some good data visualization practices. Author Stephanie Evergreen has a 24-point checklist on her website, and a previous presentation in the user group shows how to incorporate that in ggplot2
library(scales)
g6 <- ggplot(ggplot_downloads_df, # Data
aes(x = date, y = count)) + # Mapping
geom_point() + # Layer
geom_smooth() + # Layer (additional)
scale_y_continuous(
labels = label_number(
suffix = "K", scale = 1e-3)
) + # Scale
theme_minimal() + # Theme
labs(title = "ggplot2's rise in popularity over the past decade",
subtitle = "Number of daily downloads from CRAN",
x = NULL,
y = NULL) # Labels
g6library(scales)
g7 <- ggplot(ggplot_downloads_df, # Data
aes(x = date, y = count)) + # Mapping
geom_point(colour = "lightgrey") + # Layer
geom_smooth() + # Layer (additional)
scale_y_continuous(
labels = label_number(
suffix = "K", scale = 1e-3)
) + # Scale
theme_minimal() + # Theme
labs(title = "ggplot2's rise in popularity over the past decade",
subtitle = "Number of daily downloads from CRAN",
x = NULL,
y = NULL) # Labels
g7RStudio
HTML documents
Word/Powerpoint files
Markdown documents
Books
Websites
Interactive apps
Copy + Paste them in emails, reports, briefing notes, etc.
ggplot2 extensionsggplot2 graphs in R Markdown/Quarto reportsggplot2 objects within Shiny appsggiraph or ggplotly packagesggplot2 with base R or different librariesOfficial website: https://ggplot2.tidyverse.org/index.html
Cheat sheet: https://github.com/rstudio/cheatsheets/blob/main/data-visualization.pdf
Book of common plots: https://r-graphics.org/
Example graphs (includes non-ggplot2 examples): https://r-graph-gallery.com/
Good data visualization practices by Stephanie Evergreen: https://www.datavisualizationchecklist.com/
Implementing Stephanie Evergreen checklist in ggplot2: https://raw.githack.com/najsaqib/naj_lab/main/data_viz_checklist.html